package com.syedu.day06.v2;

/**
 * description：
 * @author Administrator
 * @date 2022/3/15 14:42
 */
public class TestUser {
    public static void main(String[] args) {
        //创建用户(没有地址信息)
        User user = new User("admin", "123456");

        //创建地址对象
        Address address1 = new Address("江苏省", "苏州市", "工业园区", "星湖街888号");
        Address address2 = new Address("江苏省", "苏州市", "吴中区", "东方大道188号");
        //使用数组存放地址对象
        Address[] addresses = {address1, address2};

        //把地址信息绑定到用户上
        user.addresses = addresses;

        //访问信息
        System.out.println("用户名:" + user.username);
        System.out.println("用户地址数: " + user.addresses.length);
        System.out.println("用户第二个地址的街道: " + user.addresses[1].street);

        //修改用户第一个地址的街道信息
        user.addresses[0].street = "星湖街999号";
        //查看修改结果
        System.out.println(user.addresses[0].street);
    }
}